﻿<%namespace name="include" file="/admin/base/include.html" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>无标题文档</title>
${include.bootstrap()}
${include.jquery()}
${include.validationEngine()}
${include.ueditor()}
${include.jqueryUI()}
</head>
<body>
<form id="dataform" class="well form-horizontal" method="post" action="/ajaxValidateSubmit" enctype="multipart/form-data">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" background="/static/admin/images/tab/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="30"><img src="/static/admin/images/tab/tab_03.gif" width="12" height="30" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="/static/admin/images/tab/tb.gif" width="16" height="16" /></div></td>
                <td width="95%" class="STYLE1">
                    <span class="STYLE3">你当前的位置</span>：[${request.params['menu1']}]-[${request.params['menu2']}]-[${id==None and u'新增' or u'编辑'}]
                </td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        <td width="16"><img src="/static/admin/images/tab/tab_07.gif" width="16" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td width="370"></td>
                <td width="370"></td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="3">
                    <div class="control-group">
                        <label class="control-label">名称</label>
                        <div class="controls">
                            <input name="name" type="text" id="name" value="${coupon and coupon.name or ''}" class="input-medium validate[required, maxSize[20]" ${coupon and 'disabled="disabled' or ''}"/>
                        </div>
                    </div>
                </td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="3">
                    <div class="control-group">
                        <label class="control-label">类别</label>
                        <div class="controls">
                            <select name="coupontype" class="input-medium validate[required]">
                                <option value="">--请选择--</option>
                                %if coupon:
                                ${h.getoptions('coupontype', str(coupon.coupontype))|n}
                                %else:
                                ${h.getoptions('coupontype')|n}
                                %endif
                            </select>
                        </div>
                    </div>
                </td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label">有效期</label>
                        <div class="controls controls-row">
                                <input id="startdate" name="startdate" type="text" value="${coupon and h.date(coupon.startdate) or ''}" class="input-medium validate[required, custom[date]]"/> -- <input id="enddate" name="enddate" type="text" value="${coupon and h.date(coupon.enddate) or ''}" class="input-medium validate[required, custom[date]]"/>
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label" for="name">数量</label>
                        <div class="controls">
                            <input name="number" type="text" value="${coupon and coupon.number or ''}" class="input-medium validate[custom[integer]]"/>
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label" for="name">规则</label>
                        <div class="controls">
                            <input name="rule" type="text" value="${coupon and coupon.rule or ''}" class="input-small"/>
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label" for="name">图片</label>
                        <div class="controls">
                            <input name="picture" type="file"/>
                            <span class="help-block">请上传260*180大小的图片</span>
                            %if coupon and coupon.picture:
                            <span class="help-block"><img src="${coupon.picture}" class="img-polaroid"/></span>
                            %endif
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label" for="name">详细</label>
                        <div class="controls">
                            <textarea id="detail" name="detail">${coupon and coupon.detail or ''}</textarea>
                            <script type="text/javascript">
                                var editor_a = new baidu.editor.ui.Editor({
                                        initialContent:'',
                                        minFrameHeight:150,
                                        });
                                editor_a.render('detail');
                            </script>
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="2">
                    <div class="control-group">
                        <label class="control-label" for="name">商家</label>
                        <div class="controls">
                            <select name="businessUser_id" class="input-medium validate[required]">
                                <option value="">--请选择--</option>
                                %if coupon:
                                ${h.get_table_options('BusinessUser', 'id', 'companyname', str(coupon.coupontype))|n}
                                %else:
                                ${h.get_table_options('BusinessUser', 'id', 'companyname')|n}
                                %endif
                            </select>
                        </div>
                    </div>
                </td>
                <td></td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
            <tr>
                <td width="8" background="/static/admin/images/tab/tab_12.gif">&nbsp;</td>
                <td colspan="3">
                    <div class="form-actions">
                        %if businessuser:
                        <input type="hidden" name="id" value="${id}"/>
                        %endif
                        <input type="hidden" name="form.submitted" value="save"/>
                        <input type="hidden" name="action" id="action"/>
                        <button class="btn btn-info" type="submit" id="savedraft">保存</button>
                        <button class="btn btn-primary" type="submit" id="publish">通过上线</button>
                        <button class="btn btn-primary" type="reset">重置</button>
                        <button class="btn btn-primary">返回</button>
                    </div>
                </td>
                <td width="8" background="/static/admin/images/tab/tab_15.gif">&nbsp;</td>
            </tr>
        </table>
    </td>
  </tr>
  <tr>
    <td height="35" background="/static/admin/images/tab/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="35"><img src="/static/admin/images/tab/tab_18.gif" width="12" height="35" /></td>
        <td>
        </td>
        <td width="16"><img src="/static/admin/images/tab/tab_20.gif" width="16" height="35" /></td>
    </tr>
</table>
</td>
  </tr>
</table>
</form>
<script type="text/javascript">
function ajaxValidationCallback(status, form, json, options)
{
    if(status)
    {
        form.attr('action', '${request.url}');
        form.validationEngine('detach');
        form.submit();
    }
}

$(document).ready(function(){
    $('#dataform').validationEngine({
            ajaxFormValidation: true,
            onAjaxFormComplete: ajaxValidationCallback,
    })
    $("#startdate").datepicker({
        defaultDate: "+1d",
        changeMonth: true,
        minDate: +1,
        onClose: function(selectedDate) {
            $("#enddate").datepicker("option", "minDate", selectedDate);
        }
    });
    $("#enddate").datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        onClose: function(selectedDate) {
            $("#startdate").datepicker("option", "maxDate", selectedDate);
        }
    });
    $("#ui-datepicker-div").css('font-size','82.5%');
    
    $('#savedraft').click(function(){
        $('#action').val('savedraft')
    })
    $('#publish').click(function(){
        $('#action').val('publish')
    })

});
</script>
</body>
</html>
